<?php
/**
 * Description of loadProperties
 *
 * @author rocco
 */

class LoadProperties
{
    private $host;
    private $user;
    private $database;
    private $password;
    private $path;
    private $uploadPath;
    private $errors;
//    private $numConnection;

    public function initServices()
    {
        $fileProp=fopen("../utility/services.properties","r");

        $buffer = fgets($fileProp);
        $tmp1 = explode("=", $buffer);
        $this->path = trim($tmp1[1]);

        $buffer = fgets($fileProp);
        $tmp1 = explode("=", $buffer);
        $this->uploadPath = trim($tmp1[1]);

        fclose ($fileProp);

    }

    public function initErrors()
    {
        $this->errors = array();

        $fileErrors=fopen("../utility/errors.properties","r");
        while( ($buffer = fgets($fileErrors))!=NULL)
        {
            $tmp1 = explode("=", $buffer);
            $this->errors[trim($tmp1[0])] = trim($tmp1[1]);
        }

        fclose ($fileErrors);
    }

    public function initDB()
    {
        $fileProperties=fopen("../utility/db.properties","r");
//lettura host
        $buffer = fgets($fileProperties);
        $tmp1 = explode("=", $buffer);
        $this->host = trim($tmp1[1]);

//lettura user
        $buffer = fgets($fileProperties);
        $tmp2 = explode("=", $buffer);
        $this->user =trim($tmp2[1]);

        //lettura db
        $buffer = fgets($fileProperties);
        $tmp3 = explode("=", $buffer);
        $this->database =trim($tmp3[1]);

        //lettura password
        $buffer = fgets($fileProperties);
        $tmp4 = explode("=", $buffer);
        $this->password =trim($tmp4[1]);

//        //lettura numConnection
//        $buffer = fgets($fileProperties);
//        $tmp5 = explode("=", $buffer);
//        $this->numConnection =trim($tmp5[1]);

        fclose ($fileProperties);

    }

    public function getHost()
    {
        return $this->host;
    }

    public function getUser()
    {
        return $this->user;
    }

    public function getDatabase()
    {
        return $this->database;
    }

    public function getPassword()
    {
        return $this->password;
    }

    public function getPath()
    {
        return $this->path;
    }

    public function getUploadPath()
    {
        return $this->uploadPath;
    }

    public function getErrors()
    {
        return $this->errors;
    }

//    public function getNumConnection()
//    {
//        return $this->numConnection;
//    }
}
?>
